// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()
const db = cloud.database()
// 云函数入口函数
exports.main = async (event, context) => {
  try {
    const {_openid} = event
    return await db.collection('users').where({_openid})
      .field({
        _id: true,
        avatarUrl: true,
        nickName: true
      })
      .get()
  } catch (err) {
    console.error(err)
  }
}